#ifndef NODEGRAPHICS_H
#define NODEGRAPHICS_H

#include <QGraphicsItem>
#include <QPainter>
#include <QObject>
#include <QGraphicsSceneMouseEvent>
#include <vector>
#include <map>
#include <QPixmap>
#include <iostream>
#include <QToolTip>
#include <QHelpEvent>
#include <QPicture>

enum ACTION {
    SET_SADDLES,
    SHOW_WAY,
    SET_INIT,
    SET_END,
    SHOW_HIDE_LISTS,
    UPDATE
};


enum LAB {
    EMPTY = 0,
    WALL = 1,
    PAS = 2,
    INIT = 3,
    OPEN = 4,
    CLOSE = 5,
    END = 6,
    CAM_TMP
};




struct pair{
    int row,col;
    pair(int row_, int col_) {
        row = row_;
        col = col_;
    }
};

struct pairLess
{
    bool operator()(const pair& lst, const pair& rst) const {
        if(rst.row < lst.row)
            return true;
        else if(rst.row == lst.row && rst.col < lst.col)
            return true;
        return false;
    }
};

class NodeGraphics:public QObject,public QGraphicsItem
{
    Q_OBJECT
public:
    NodeGraphics();
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
               QWidget *widget);
    QRectF boundingRect() const;
    void setType(LAB c);
    QColor color;
    LAB type;
    void setRowCol(int row_, int col_);
    int col,row;
    QPainterPath shape() const;
    void mousePressEvent ( QGraphicsSceneMouseEvent * event );
    void hoverEnterEvent ( QGraphicsSceneHoverEvent *event);
    void hoverLeaveEvent ( QGraphicsSceneHoverEvent *event);
    static std::map<pair,NodeGraphics*,pairLess> NodesMap;
    static NodeGraphics *itemFocused;

signals:
    void repaint(int row, int col, ACTION a);
    void menuSignal(int row, int col,QPoint pos);
    
private:
    QPixmap door;
    QPixmap grama;
    QPixmap wall;

};

#endif // NODEGRAPHICS_H
